<?php

$basepath = $_SERVER['DOCUMENT_ROOT'];
require_once($basepath. '/mapblogs/app_config/app_config_v2_sum2_08.php');


$section = htmlspecialchars(strip_tags(utf8_encode($_GET['sec'])));
$category = htmlspecialchars(strip_tags(utf8_encode($_GET['category'])));
$g_course_id = htmlspecialchars(strip_tags(utf8_encode($_GET['cid'])));
$tempvar = "";


$conn = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name, $conn);

//$query = "select * from " . $g_mapblog_table_name . " where course_id = '" . $g_course_id . "' and section = " . $section . " and category = '" . $category . "'";

$query = "select * from " . $g_mapblog_table_name . " where course_id = '" . $g_course_id . "' and section = " . $section . " and active_record = true and userid <> 'kent' order by userid, add_date";

$result = mysql_query($query, $conn);
$num_result = mysql_num_rows($result);

$latvar = 0;
$longvar = 0;

$tempvar = "<table style='font-size:9pt;width:1000px;'>";
$tempvar = $tempvar . "<tr style='background:#DDDDAA;'><td width='100px'><b>Student ID</b></td><td width='200px'><b>Marker Label</b></td>"
		. "<td><b>Marker URL</b></td><td width='200px'><b>Added on</b></td><td width='200px'><b>Module</b></td></tr>";

$counter = 1;
while ($row = mysql_fetch_array($result))
{
	$latvar = $row["latitude"];
	$longvar = $row["longitude"];
	$namevar = $row["place_name"];
	$urlvar = $row["page_url"];
	$userid = $row["userid"];
	$thedate = $row["add_date"];
	$row_seq_no = $row["row_seq_no"];
	$category = $row["category"];
	
	$tempVar = $counter % 2;
	if ($tempVar == 0) {
		$rowStyle ="";
	} else {
		$rowStyle ="style='background:#DDDDDD;'";
	}

	$tempUrl = substr($urlvar, 0, 70);
	$tempDate = substr($thedate, 0, 11);
	$tempvar = $tempvar . "<tr ". $rowStyle . "><td>" . $userid . "</td><td>" . $namevar 
		. "</td><td><a href='" . $urlvar . "' target='_blank'>" . $tempUrl . "</a></td><td>" . $tempDate . "</td><td>" . $category . "</td></tr>";
    $counter++;
}

$tempvar = $tempvar . "</table>";
echo $tempvar;

?>
